<form id="form_announcements_showedit" method="post" action="y.php?r=announcements/savedata">
    <input type="hidden" name="announcements_id" value="">
    <div style="margin-bottom:20px">
        <input class="easyui-textbox" name="title" style="width:100%" data-options="label:'主题:',required:true">
    </div>
    <div style="margin-bottom:20px">
        <select class="easyui-combobox" name="announcements_type" style="width:100%" data-options="label:'公告类型:',required:true">
            <option value="一般通知">一般通知</option>
            <option value="重要通知">重要通知</option>
            <option value="公司任命">公司任命</option>
            <option value="会议通知">会议通知</option>
        </select>
    </div>
    <div style="margin-bottom:20px;">
        <div class="easyui-texteditor" id="texteditor_content" title="内容" style="height:300px;padding:20px;">
            <?php
            if(!is_null($announcements)){
                echo $announcements['content'];
            }
            ?>
        </div>
        <input type="hidden" name="content"/>
    </div>
    <div style="margin-bottom:20px;">
        <input class="easyui-datetimebox" name="start_time" style="width:100%"
               data-options="label:'开始时间:',required:true">
    </div>
    <div style="margin-bottom:20px">
        <input class="easyui-datetimebox" name="end_time" style="width:100%"
               data-options="label:'结束时间:',required:true">
    </div>
</form>
<div style="text-align:center;padding:5px 0">
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width:80px">清空</a>
</div>
<script>
    var dataobj = <?php echo json_encode($announcements) ?>;
    $(function () {
        $('#form_announcements_showedit').form('load',dataobj);
    });
    function submitForm() {
        $("input[name=content]").val($('#texteditor_content').texteditor("getValue"));
        $('#form_announcements_showedit').form('submit',{
            success: function(){
                $('#win_main').window("close");
                $("#announcements_list").datagrid("reload");
            }
        });
    }
    function clearForm() {
        $('#form_announcements_showedit').form('clear');
        $('#texteditor_content').texteditor("clear")
        if(dataobj!=null){
            $("input[name=announcements_id]").val(dataobj.announcements_id);
        }
    }
</script>